#include "Ring_Queue.hpp"

void *consumer(void *args)
{
    Ring_Queue<int> *_rq = static_cast<Ring_Queue<int> *>(args);
    while (1)
    {
        int _data = _rq->Pop();
        std::cout << "consumer: " << _data << std::endl;
    }

    pthread_exit((void *)0);
}

void *productor(void *args)
{
    Ring_Queue<int> *_rq = static_cast<Ring_Queue<int> *>(args);
    int _data = 1;
    while (1)
    {
        _rq->push(_data);
        std::cout << "productor: " << _data++ << std::endl;
    }

    pthread_exit((void *)0);
}

int main()
{
    Ring_Queue<int> *_rq = new Ring_Queue<int>();

    pthread_t tid1, tid2;
    pthread_create(&tid1, nullptr, consumer, (void *)_rq);
    pthread_create(&tid2, nullptr, productor, (void *)_rq);

    pthread_join(tid1, nullptr);
    pthread_join(tid2, nullptr);

    return 0;
}